var db = require('../models');
var async = require('async');

//保存信息
exports.saveMessage = function(message,callback){
	var newMessage = db.Message();
	newMessage.mcontent = message.mcontent;
	newMessage.muser = message.muser;
	newMessage._roomId = message.roomId;
	//用户信息
	//newMessage.muser = message.user;
	newMessage.save(callback);
};

//获取信息
exports.getMessages = function(callback){
	db.Message.find({},{
		'_id':0,
		'mcontent':1,
		'mtime':1,
		'muser':1,
	},{
		sort:{
			'mtime':1
		},
		limit:20
	},callback);
}